$(document).ready(function() {
	initDatePicker();
	$("#viewStatistic").click(function(){
		var fromDate = $("#fromDate").val();
		var toDate = $("#toDate").val();
		$("#imageLoading").show();
		$.ajax({
			type: 'POST',
			url : "viewMoneyStatistic",
			data: {
				fromDate: fromDate,
				toDate: toDate
			},
			success: function(data) {
				$("#imageLoading").hide();
				$("#totalMoney").html($.number(data,',') + " VND.");
			}, 
			error: function(xrh, error) {
				$("#imageLoading").hide();
				$("#errorMessage").html("Error! Please contact to system admin!");
			}
		});
	});
});

function initDatePicker() {
	$("#fromDate").datepicker({
		showOn : 'button',
		buttonImage : IMAGES_PATH+'/calendar.gif',
		buttonImageOnly : true,
		changeMonth : true, // must be disabled when using maxDate
		changeYear : true,
		dateFormat : 'dd/mm/yy'
	});
	$("#toDate").datepicker({
		showOn : 'button',
		buttonImage : IMAGES_PATH+'/calendar.gif',
		buttonImageOnly : true,
		changeMonth : true, // must be disabled when using maxDate
		changeYear : true,
		dateFormat : 'dd/mm/yy'
	});
};